package com.superdry.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.ab.activity.AbActivity;
import com.ab.util.AbDialogUtil;
import com.drysurper.R;
import com.superdry.global.SApplication;
import com.superdry.json.Userinfo;
import com.superdry.utils.SPHelper;

public class MoreActivity extends AbActivity implements OnClickListener{

	View advise ;
	View quit;
	PopupWindow pop;
	View dialog_quit;
	View goback;
	View pingfen;
	View problem;
	View about_us;
	Userinfo userinfo;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setAbContentView(R.layout.aty_more);
		
		initView();
	}
	
	public void initView(){
		userinfo = SPHelper.getUserInfo(MoreActivity.this);
		advise = findViewById(R.id.more_advise);
		quit = findViewById(R.id.more_quit);
		goback = findViewById(R.id.goback_more);
		pingfen = findViewById(R.id.pingfen);
		problem = findViewById(R.id.problem);
		about_us = findViewById(R.id.about_us);
		
		dialog_quit = mInflater.inflate(R.layout.dialog_quit, null);
		View shade_dismiss = dialog_quit.findViewById(R.id.dialog_dismiss);
		TextView application_quit = (TextView) dialog_quit.findViewById(R.id.quit_sure);
		TextView application_quit_cancle = (TextView) dialog_quit.findViewById(R.id.quit_cancle);
		
		pop = new PopupWindow(dialog_quit, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
		pop.setFocusable(true);
		
		advise.setOnClickListener(this);
		quit.setOnClickListener(this);
		shade_dismiss.setOnClickListener(this);
		application_quit.setOnClickListener(this);
		application_quit_cancle.setOnClickListener(this);
		goback.setOnClickListener(this);
		pingfen.setOnClickListener(this);
		problem.setOnClickListener(this);
		about_us.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		
		switch (v.getId()) {
		case R.id.more_advise:
			click2NextAty(AdviseActivity.class);
			break;
			
		case R.id.more_quit:
			
			pop.showAtLocation(dialog_quit, Gravity.BOTTOM, 0, 0);
			break;
			
		case R.id.dialog_dismiss:
			
			pop.dismiss();
			break;
			
		case R.id.quit_sure:
			SApplication.getInstance().exit();
			break;
			
		case R.id.quit_cancle:
			
			pop.dismiss();
			
		case R.id.goback_more:
			finish();
			break;
			
		case R.id.pingfen:
			
			click2NextAty(PingfenActivity.class);
			break;
			
		case R.id.problem:
			
			click2NextAty(ProblemActivity.class);
			break;
			
		case R.id.about_us:
			
			click2NextAty(AboutUsActivity.class);
			break;
		default:
			break;
		}
	}
	
	public void click2NextAty(Class clazz){
		Intent intent = new Intent();
		intent.setClass(MoreActivity.this, clazz);
		startActivity(intent);
	}
}
